#!/bin/bash

set -e

if [[ -n "${RASTER_VISION_DEBUG}" ]]; then
    set -x
fi

function usage() {
    echo -n \
         "Usage: $(basename "$0") <public dns of instance>
Upload Github repo to EC2 instance
"
}

PROJECT_ROOT="$(dirname "$(dirname "$(readlink -f "${0}")")")"

if [ "${BASH_SOURCE[0]}" = "${0}" ]
then
    if [ "${1:-}" = "--help" ]
    then
        usage
    else
        EC2_HOSTNAME=$1
        echo "HOSTNAME: $EC2_HOSTNAME"

        # Copy learned models back down to the local machine
        rsync -avz -e "ssh -o StrictHostKeyChecking=no" \
            /vagrant/src --include="*.py" --exclude="*.pyc"\
            "ec2-user@$EC2_HOSTNAME:/home/ec2-user/raster-vision/src"
    fi
fi
